import math
import os
import random
import torch
from d2l import torch as d2l
import  re

def read_time_machine():
    d2l.DATA_HUB['time_machine'] = (d2l.DATA_URL + 'timemachine.txt',
                                    '090b5e7e70c295757f55df93cb0a180b9691891a')
    with open(d2l.download('time_machine'), 'r') as f:
        lines = f.readlines()
    lines = [line.replace("\n"," ") for line in lines if line != "\n"]
    sentences = "".join(lines)
    return sentences